#include "factory.h"


//随机盐值
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#define LENGTH 19

void generate_random_string(char *random_string) 
{
    char *charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    int i;

    srand(time(NULL)); // 设置种子
    
    for (i = 3; i < LENGTH; ++i) {
        random_string[i] = charset[rand() % (strlen(charset) - 1)];
    }

    random_string[LENGTH] = '\0'; // 添加字符串结尾
}


off_t get_file_name_pos(char *file_name_and_len)
{
    int i;
    for(i=0;i<strlen(file_name_and_len);i++)
    {
        if(file_name_and_len[i]==' ')
        {
            break;
        }
    }
    // 把空格换为\0
    file_name_and_len[i]='\0';
    char seek_pos[100];
    strcpy(seek_pos,file_name_and_len+i+1);
    return atol(seek_pos);
}
